package edu.ccut.saturn.authority.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;

public class GetSubMenu extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		
		List<Map<String, Object>> list = (ArrayList<Map<String, Object>>)parameterContext.getParameterValue(0);
		String menuId = (String)parameterContext.getParameterValue(1);
		List<Object> result = new ArrayList<Object>();
		if(list != null){
			for(Map<String, Object> map :list){
				if(map.get("id").equals(menuId)){
					result = (List)map.get("children");
					break;
				}
			}
		}
		parameterContext.setParameter(0, result);
	}
}